//
//  WarmTipsViewController.m
//  CoolTennisBall
//
//  Created by CA on 16/6/21.
//  Copyright © 2016年 CoolLang. All rights reserved.
//

#import "WarmTipsViewController.h"
#import "NSBundle+CurrentLanguage.h"

@interface WarmTipsViewController ()
@property (weak, nonatomic) IBOutlet UILabel *titleLabel;
@property (weak, nonatomic) IBOutlet UILabel *tipsLabel;
@property (weak, nonatomic) IBOutlet UILabel *bottomLabel;
@property (weak, nonatomic) IBOutlet UIImageView *tipsImageView;

@end

@implementation WarmTipsViewController

#pragma mark - View LifeCycle

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self configureLocalization];
}

#pragma mark - Localization

- (void)configureLocalization
{
    self.titleLabel.text = NSLocalizedString(@"Thank you for your support for our intelligent tennis products!", nil);
    if (![NSBundle currentLanguageIsChinese]) {
        self.tipsLabel.text  = NSLocalizedString(@"Your device would generate small amounts of data during transport, it is a normal phenomenon, you can clear the data by swipe left.", nil);
        NSString *tipStr = @"Your device would generate small amounts of data during transport, it is a normal phenomenon, you can clear the data by ";
        NSString *subStr1 = @"swipe left";
        NSString *subStr2 = @".";
        if ([NSBundle currentLangeuage] == kLanguageFrennch){
            tipStr = @"Votre appareil peut générer des faibles mesures durant le transport, c'est un phénomène normal, vous pouvez supprimer ces données en les ";
            subStr1 = @"déplaçant vers la gauche";
            subStr2 = @" sur l'écran tactile du smartphone/tablette.";
        }
        NSMutableAttributedString *attributedStr = [[NSMutableAttributedString alloc] initWithString:tipStr];
        NSAttributedString *keyWord = [[NSAttributedString alloc] initWithString:subStr1 attributes:@{NSForegroundColorAttributeName: [UIColor colorWithHex:0xFF855F]}];
        NSAttributedString *period = [[NSAttributedString alloc] initWithString:subStr2];
        [attributedStr appendAttributedString:keyWord];
        [attributedStr appendAttributedString:period];
        self.tipsLabel.attributedText = attributedStr;
    }
    self.bottomLabel.text = NSLocalizedString(@"Swipe Left to Delete", nil);
    self.tipsImageView.image = [UIImage imageNamed:NSLocalizedString(@"sport_icon_tips_en", nil)];
}

#pragma mark - IBAction
- (IBAction)dismiss:(id)sender {
    
    if (self.dismissBlock) {
        self.dismissBlock();
        self.dismissBlock = nil;
    }
    
    [self dismissFromParentViewControllerWithAnimationType:DetailViewControllerAnimationTypeFade];
}


@end
